package com.virtualCat.controller.portal;

import com.virtualCat.common.Msg;
import com.virtualCat.service.OrderService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/mine")
@Api(value = "mine",description="点击“我的”,订单查询的接口")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @RequestMapping(value = "/mineInfo",
            method = RequestMethod.GET,
            produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value="查询我的信息",httpMethod="GET",notes="查询我的信息")
    @ResponseBody
    public Msg queryMineInfo(@RequestParam("openid")String openid){
        return orderService.mineInfo(openid);
    }

    @RequestMapping(value = "/order_list",
            method = RequestMethod.GET,
            produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value="订单列表",httpMethod="GET",notes="订单列表")
    @ResponseBody
    public Msg queryListByStatus(@RequestParam("openid")String openid,@RequestParam("status")int status){
        return orderService.queryOrderNumberAndList(openid,status);
    }

    @RequestMapping(value = "/order_detail",
            method = RequestMethod.GET,
            produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value="订单详细信息",httpMethod="GET",notes="订单详细信息")
    @ResponseBody
    public Msg queryOrderDetail(@RequestParam("order_id")String order_id){
        return orderService.queryOrderDetail(order_id);
    }

    @RequestMapping(value = "/confirm_receipt",
            method = RequestMethod.GET,
            produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value="订单详细信息",httpMethod="GET",notes="订单详细信息")
    @ResponseBody
    public Msg confirmReceipt(@RequestParam("order_id")String order_id){
        return orderService.updateOrderStatus(order_id);
    }
}
